<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/static/common/default.jsp"%>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<style type="text/css">
		.advance_tip_pwd{
			background-color: #fff;
		    left: 42%;
		    position: fixed;
		    top: 200px;
		    width: 487px;
		    z-index: 5;
		}
		</style>
	</head>
	<body>
		<div class="cinema_tip">
		    <div class="cinema_subject clearfix">
		        <div class="cinema_title">
		            <a href="#">用户中心</a>
		            >
		            <a href="#" class="cinema_option">权限管理</a>
		        </div>
		    </div>
		    
		    
		</div>
		
		<div class="cinema_list">
			<div class="movie_button">
		    	<shiro:hasPermission name="sysUserInfo:add">
					<a class="movie_new" href="${ctx}/sys/resource/toAdd/-1" style="background-color: rgb(75, 208, 131); color: rgb(255, 255, 255);">新建</a>
				</shiro:hasPermission>
			</div>
			
			<div  class="column_content">
				<div class="column_content1">
				<table id="sysUserInfoDatas" width="100%" height="" border="0" cellpadding="0" cellspacing="1" class="border_top">
					<tr style="background-color: rgb(243, 247, 255);">
						<th nowrap="" style="padding:0px 5px;width: 30px">ID</th>
						<th nowrap=""  colspan="2">名称</th>
			            <th nowrap="" >类型</th>
			            <th nowrap="" style="padding:0px 5px;">路径</th>
			            <th nowrap="" style="padding:0px 5px;width:100px">序号</th>
			            <th nowrap="" style="padding:0px 5px;">操作</th>
			        </tr>
			        <c:forEach var="res" items="${list}"  varStatus="status">
			        <tr class="odd" style="background-color: rgb(255, 255, 255);" id="userinfo_row_${res.resourceId}" >
			        	<td>${status.index+1}</td>  
			        	<td nowrap="" colspan="2" style="padding:0px 5px;">${res.resName}&nbsp;</td>
			        	<td nowrap="" >
			        		<c:choose>
				            	<c:when test="${res.type ==1}">菜单</c:when>
				            	<c:otherwise>按钮</c:otherwise>
				            </c:choose>
			        	</td>
			        	<td nowrap="" style="padding:0px 5px;">${res.resUrl}&nbsp;</td>
			        	<td nowrap="" style="padding:0px 5px;" title="${res.indexNum}">${res.indexNum}&nbsp;</td>
			        	<td nowrap="" style="padding:0px 5px;width:150px;text-align:left" >
				            <a style="margin-left: 3%;" href="${ctx}/sys/resource/toUpdate/${res.resourceId}">编辑</a>
				            <c:if test="${res.havechild !=1}">
				            <a style="margin-left: 3%;" href="javascript:deleteRes(${res.resourceId});">删除</a>
				            </c:if>
				            <a style="margin-left: 3%;" href="${ctx}/sys/resource/toAdd/${res.resourceId}">添加</a>
						</td>
			        </tr>
			        
			        <c:if test="${res.havechild ==1}">
			        <c:forEach var="res1" items="${res.list}"  varStatus="status1">
			        <tr class="odd" style="background-color: rgb(255, 255, 255);" id="userinfo_row_${res1.resourceId}">
			        	<td>&nbsp;</td>  
			        	<td>&nbsp;</td>
			        	<td nowrap="" style="padding:0px 5px;text-align:right">${res1.resName}&nbsp;</td>
			        	<td nowrap="" >
			        		<c:choose>
				            	<c:when test="${res1.type ==1}">菜单</c:when>
				            	<c:otherwise>按钮</c:otherwise>
				            </c:choose>
			        	</td>
			        	<td nowrap="" style="padding:0px 5px;">${res1.resUrl}&nbsp;</td>
			        	<td nowrap="" style="padding:0px 5px;">${res1.indexNum}&nbsp;</td>
			        	<td nowrap="" style="padding:0px 5px;width:150px;text-align:left" >
				            <a style="margin-left: 3%;" href="${ctx}/sys/resource/toUpdate/${res1.resourceId}">编辑</a>
				            <a style="margin-left: 3%;" href="javascript:deleteRes(${res1.resourceId});">删除</a>
						</td>
			        </tr>
			        </c:forEach>
			        </c:if>
			        </c:forEach>
				</table>
				</div>
			</div>
		</div>
		<script type="text/javascript">
		function deleteRes(resourceId){
			if(confirm("您确认删除该条记录吗?")){
				//resetRowById(userId);
				$.ajax({
					type : "DELETE",
					dataType: "json",
					async: false,
					url: '${ctx}/sys/resource/delete/'+resourceId,
					success: function (data) {
								if(data!=undefined&&data.status!=undefined&&data.status.trim()=="0"){
									$("#userinfo_row_"+resourceId).remove();
									alert("删除成功。");
								}else{
									alert("error:"+data.error);
								}
							 },
					error: function(data) {
								alert("删除失败。");
							}
				});
				return false;
			}
		}
		</script>
	</body>

</html>